unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdFTP,
  Vcl.StdCtrls, rtcGateSrv, rtcInfo, rtcConn, rtcDataCli, rtcHttpCli, rtcTcpCli,
  rtcTcpSrv;

type
  TForm1 = class(TForm)
    Btnx_1: TButton;
    IdFTP1: TIdFTP;
    Btnx_2: TButton;
    RtcHttpClient1: TRtcHttpClient;
    rtcgtwy1: TRtcGateway;
    rtctcpclnt1: TRtcTcpClient;
    cpServer1: TRtcTcpServer;
    procedure Btnx_1Click(Sender: TObject);
    procedure IdFTP1Connected(Sender: TObject);
    procedure Btnx_2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  class_kzdebug,IdGlobal,IdFTPCommon;

{$R *.dfm}

procedure TForm1.Btnx_1Click(Sender: TObject);
var
  ListA:TStringList;
begin
  IdFTP1.Host      :='192.168.0.29';
  IdFTP1.Port      :=21;
  IdFTP1.Username  :='xmf';
  IdFTP1.Password  :='xmf';


  try
    if not IdFTP1.Connected then
    begin
      IdFTP1.Connect;
    end;
    IdFTP1.IOHandler.DefStringEncoding:=IndyTextEncoding_UTF7;

    ListA:=TStringList.Create;
    IdFTP1.List;
    ListA.AddStrings(IdFTP1.ListResult);
    KzDebug.FileLog(ListA.Text);
    FreeAndNil(ListA);
  except
    on E:Exception do
    begin
      raise Exception.Create(E.Message);
    end;
  end;
end;

procedure TForm1.Btnx_2Click(Sender: TObject);
begin
  if IdFTP1.Connected then
  begin
    IdFTP1.Disconnect;
  end;
end;

procedure TForm1.IdFTP1Connected(Sender: TObject);
begin
  KzDebug.FileLog('ftp:connected');
  IdFTP1.IOHandler.DefStringEncoding:= IndyTextEncoding(encASCII);
end;

end.
